from abc import abstractmethod
from typing import Any
import torch.nn as nn
from continuallearning.interfaces.core.component import ComponentInterface


class HookFactoryInterface(ComponentInterface):
    """
    Protocol defining the interface for hook factory callables.

    Hook factories are responsible for creating hooks for specific modules
    in a model. This protocol allows registering and using different hook
    implementation strategies in a type-safe manner.
    """

    @abstractmethod
    def __call__(self, module_path: str, module: nn.Module) -> Any:
        """
        Create a hook for the given module.

        Args:
            module_path: Path to the module in the model
            module: The module to hook

        Returns:
            HookInterface: A hook instance for the module
        """
        ...

    @property
    @abstractmethod
    def config(self) -> Any:
        """
        Get the configuration for this hook factory.


        Returns:
            Any: Configuration object for this factory
        """
        pass
